package main.inquiry;

import base.BaseCanvasWindow;

import dao.MakeupNoticeCanvasDao;
import model.MakeupNotice;

import java.awt.*;
import java.util.List;

public class MakeupNoticeCanvas extends BaseCanvasWindow {

    @Override
    protected String setCanvasTitle() {
        return "补考通知单";
    }

    @Override
    protected Canvas setCanvasContent() {
        return new MakeupNoticeArea();
    }

    class MakeupNoticeArea extends Canvas    //各个画布用于打印信息
    {
        public void paint(Graphics g) {
            g.setColor(Color.BLACK);
            g.drawString("以下为补考名单", 80, 20);
            g.drawString("学号", 10, 40);
            g.drawString("姓名", 80, 40);
            g.drawString("补考课程", 150, 40);

            try {
                List<MakeupNotice> list = MakeupNoticeCanvasDao.getMakeupNotices();
                int length = list.size();

                for (int i = 0; i < length; i++) {
                    MakeupNotice makeupNotice = list.get(i);
                    String sno = makeupNotice.getSno();
                    String sname = makeupNotice.getSname();
                    String cname = makeupNotice.getCname();

                    g.drawString(sno, 10, 60 + 20 * i);
                    g.drawString(sname, 80, 60 + 20 * i);
                    g.drawString(cname, 150, 60 + 20 * i);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
